/* ============================================
   Village Portal - Global CSS
   Shared styles for all pages
   ============================================ */

:root {
  --color-primary: #0052CC;
  --color-primary-dark: #003d99;
  --color-primary-light: #4F8CFF;
  --color-secondary: #22223b;
  --color-text: #22223b;
  --color-text-light: #4b5563;
  --color-placeholder: #999;
  --color-border: #ddd;
  --color-error: #d32f2f;
  --color-success: #10b981;
  --color-bg-light: #f8f8f8;
  --color-white: #ffffff;
  --color-accent: #e0e7ff;
  --font-main: Arial, 'Helvetica Neue', sans-serif;
  --radius: 4px;
  --transition: 150ms ease;
}

/* ============================================
   Reset & Base Styles
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-white);
  margin-left: 250px;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  body {
    margin-left: 0;
  }
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-dark);
}

/* ============================================
   Header & Navigation
   ============================================ */

.portal-header {
  background: linear-gradient(135deg, #1a5490 0%, #0052CC 100%);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  flex-wrap: nowrap;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--color-white);
  flex-shrink: 0;
  min-width: 0;
}

.logo-img {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px;
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.portal-tagline {
  font-size: 0.8rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.portal-nav {
  position: fixed;
  left: 0;
  top: 0;
  width: 250px;
  height: 100vh;
  background: linear-gradient(135deg, #1a5490 0%, #0052CC 100%);
  padding: 2rem 0;
  z-index: 101;
  overflow-y: auto;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-link {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  padding: 1rem 1.5rem;
  border-radius: 0;
  transition: all var(--transition);
  display: block;
  border-left: 4px solid transparent;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--color-white);
  border-left: 4px solid var(--color-white);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--color-white);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.owner-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  color: #FFD700;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.9rem;
}

.owner-icon {
  font-size: 1rem;
}

.owner-label {
  font-size: 0.9rem;
}

/* ============================================
   Alerts / Notifications System
   ============================================ */

.notification-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.notification-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--color-white);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  position: relative;
}

.notification-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.notification-badge-main {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff4d4d;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #0052CC;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(255, 77, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 360px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  border: 1px solid #f0f0f0;
  animation: fadeInDown 0.25s ease;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.notification-dropdown.show {
  display: flex;
}

.notification-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}

.notification-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification-header-left h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.notification-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notif-mark-read {
  background: transparent;
  border: none;
  color: #0052CC;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

.notif-mark-read:hover {
  background: #f0f7ff;
  color: #003d99;
}

.notif-close-btn {
  background: #f5f5f5;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.notif-close-btn:hover {
  background: #eeeeee;
  color: #333;
}

.notification-tabs {
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid #f0f0f0;
  gap: 4px;
}

.notification-tab {
  padding: 12px 10px;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.notification-tab.active {
  color: #0052CC;
  border-bottom: 2px solid #0052CC;
}

.tab-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 10px;
  color: white;
  min-width: 18px;
  height: 18px;
}

.tab-badge.all { background: #0052CC; }
.tab-badge.actions { background: #ff9800; }
.tab-badge.notifications { background: #00c4a7; }

.notification-list {
  max-height: 380px;
  overflow-y: auto;
  background: #ffffff;
}

.notification-empty {
  padding: 60px 20px;
  text-align: center;
  color: #999;
  font-size: 1rem;
}

.notification-item {
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f9f9f9;
  transition: background 0.2s ease;
  position: relative;
}

.notification-item:hover {
  background: #f8faff;
}

.notification-item.unread {
  background: #f0f7ff;
}

.notification-item.unread::after {
  content: '';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: #0052CC;
  border-radius: 50%;
}

.notif-icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.notif-content {
  flex: 1;
}

.notif-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  line-height: 1.4;
}

.notif-desc {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.5;
  margin-bottom: 4px;
}

.notif-meta {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 4px;
}

.notif-time {
  font-size: 0.75rem;
  color: #999;
}

/* ============================================
   Footer
   ============================================ */

.portal-footer {
  background: linear-gradient(135deg, #1a5490 0%, #0052CC 100%);
  color: var(--color-white);
  padding: 3rem 1rem 1rem;
  margin-top: 3rem;
  margin-left: -250px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-left: 250px;
}

.footer-section {
  margin-bottom: 1rem;
}

.footer-section h3,
.footer-section h4 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.footer-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.footer-text {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.footer-desc {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.9);
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--color-white);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  margin-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-left: 250px;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ============================================
   Toast Notification
   ============================================ */

.toast-notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  padding: 16px 32px;
  border-radius: 8px;
  background: var(--color-secondary);
  color: var(--color-white);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 10000;
  max-width: 500px;
  min-width: 250px;
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0;
  word-wrap: break-word;
  white-space: normal;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-notification.toast-success {
  background: var(--color-success);
}

.toast-notification.toast-error {
  background: var(--color-error);
}

.toast-notification.toast-info {
  background: var(--color-primary);
}

/* ============================================
   Owner Badge
   ============================================ */

.owner-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  color: #FFD700;
  font-weight: 600;
  margin-right: 0.5rem;
}

.owner-icon {
  font-size: 1rem;
}

.owner-label {
  font-size: 0.9rem;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
  body {
    margin-left: 0;
  }

  .portal-nav {
    position: fixed;
    left: -250px;
    transition: left 0.3s ease;
    z-index: 102;
  }

  .portal-nav.active {
    left: 0;
  }

  .mobile-menu-btn {
    display: flex;
    z-index: 103;
  }

  .mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
  }

  .mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
  }

  .nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .nav-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  body.menu-open {
    overflow: hidden;
  }

  .footer-content {
    margin-left: 0;
  }

  .footer-bottom {
    margin-left: 0;
  }

  /* Responsive Table Wrapper */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }

  table {
    width: 100%;
    min-width: 600px; /* Force scroll on small screens */
  }

  /* Better Touch Targets */
  button, 
  .nav-link, 
  .footer-links a, 
  .feature-card {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .header-actions {
    gap: 0.5rem;
  }

  /* Modal Responsiveness */
  .modal-content {
    width: 95%;
    margin: 10px;
    max-height: 85vh;
  }

  /* Sticky Header for Mobile */
  .portal-header {
    padding: 0.5rem 0;
  }
}

@media (max-width: 480px) {
  .header-logo {
    gap: 0.5rem;
  }

  .logo-text h1 {
    font-size: 1.2rem;
  }

  .portal-tagline {
    font-size: 0.7rem;
  }

  .nav-link {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
  }

  .toast-notification {
    top: 60px;
    max-width: calc(100% - 20px);
    min-width: auto;
  }
}